package com.cskaoyan.dbutils;

import com.cskaoyan.others.DruidUtils;
import com.cskaoyan.vo.Account;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;

import java.sql.SQLException;

/**
 * 创建日期: 2021/11/25 16:13
 *
 * @author ciggar
 */
public class BeanHandlerDemo {


    public static void main(String[] args) throws SQLException {

        // 1. 获取QueryRunner
        QueryRunner queryRunner = new QueryRunner(DruidUtils.getDataSource());

        // 2. 执行SQL语句
        Account account = queryRunner.query("select * from account where id > ?",new BeanHandler<>(Account.class),2);

        System.out.println(account);
    }
}
